﻿package commands 
{
	import flash.utils.ByteArray;
	import commands.classesinfo.*;
	/**
	 * ...
	 * @author wwx
	 * 50000003 发三张公共牌
	 */
	public class AssignPublicCardCmd extends abCommand 
	{
		
		public function AssignPublicCardCmd() //: abCommand(CommandType.CMD_TYPE_ASSIGNPUBLICCARD)  
		{
			super(CommandType(CommandType.CMD_TYPE_ASSIGNPUBLICCARD));
			cardsInfo = new Array();
		}
		
		public var msgSeq:int;//消息号
		public var errorNum:int;//错误号	
		
		public var deskId:int;//桌子id
		
		public var countOfCard:int;//多少张公牌
		public var cardsInfo:Array;//
		
		public function convertToCmd(bytes:ByteArray, offset:int, len:int):int
		{
			var ret:int = -1;
			msgSeq = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
			offset += 4;
			errorNum = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			deskId = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			countOfCard = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			//cardsInfo = new Array();
			var cardInfo:CardInfo = null;

			for (var i:int = 0; i < countOfCard; i++)
			{
				cardInfo = new CardInfo();
				cardInfo.colorOfCard = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
				offset += 4;
				cardInfo.contentOfCard = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
				offset += 4;
				
				cardsInfo[i] = cardInfo;
			}
			return 0;
		}		
	}
	
}